import axios from "axios";
import service from "@/config/index";

const URLS = {
  SEARCH: `${service.serviceCert}/contract/search`,
  SENDOUT: `${service.serviceCert}/contract/submit`
};

export default {
  search (filter) {
    return axios.post(URLS.SEARCH, filter);
  },
  // 创建合同
  createContract (filter) {
    return axios.post(`${service.serviceCert}/cert/contract/create`, filter);
  },
  // 更新合同
  updateContract (filter) {
    return axios.post(`${service.serviceCert}/cert/contract/update`, filter);
  },
  // 获取合同详情
  getDetail (contractId) {
    return axios.get(`${service.serviceCert}/cert/contract/getById/${contractId}`);
  },
  // 发送合同
  sendContract (filter) {
    return axios.post(`${service.serviceCert}/cert/contract/draft/create`, filter);
  },
  // 拒绝合同
  refuse (params) {
    return axios.post(`${service.serviceCert}/cert/contract/refuse`, params);
  },
  // 签署合同
  sign (params) {
    return axios.post(`${service.serviceCert}/cert/contract/sign`, params);
  },
  // 获取pdf链接
  getPdfUrl (contractId) {
    return axios.get(`${service.serviceCert}/cert/contract/getUrl/${contractId}`);
  },
  // 撤回
  recall (params) {
    return axios.post(`${service.serviceCert}/cert/contract/cancel`, params);
  },
};
